import docx
from .base import ContentExtractor, FileReadError


class DocxExtractor(ContentExtractor):
    """Word文档提取器"""

    def extract(self, file_path: str) -> str:
        try:
            doc = docx.Document(file_path)
            return '\n'.join([para.text for para in doc.paragraphs])
        except Exception as e:
            raise FileReadError(file_path, str(e))